package com.xyd.service.impl;

import com.xyd.entity.ProductCategory;
import com.xyd.mapper.ProductCategoryMapper;
import com.xyd.service.ProductCategoryService;
import com.xyd.util.MybatisUtil;
import java.util.List;
import org.apache.ibatis.session.SqlSession;

/**
 * 类描述：
 *
 * @author 张吉哲
 * @date 2021/1/11 16:32
 */
public class ProductCategoryServiceImpl implements ProductCategoryService {

  private SqlSession sqlSession;

  @Override
  public List<ProductCategory> adminGetAllCategory() {
    sqlSession = MybatisUtil.getSqlSession();
    List<ProductCategory> productCategoryList = sqlSession.getMapper(ProductCategoryMapper.class)
        .adminGetAllCategory();
    MybatisUtil.closeSqlSession(sqlSession);
    return productCategoryList;
  }
  @Override
  public long getIdByName(String name) {
    sqlSession= MybatisUtil.getSqlSession();
    long x=sqlSession.getMapper(ProductCategoryMapper.class).getIdByName(name);
    MybatisUtil.closeSqlSession(sqlSession);
    return x;
  }

  public static void main(String[] args) {
    ProductCategoryServiceImpl productCategoryService = new ProductCategoryServiceImpl();
    System.out.println(productCategoryService.getIdByName("画册"));
  }
}
